<template>
	<view>
		<view class="box" @click="change()">
			<image class="image" src="../../static/default-avatar.png" mode=""></image>
			<text class="app" >{{list}}</text>
			<!-- <text class="app"  v-if="list.length == 0">{{title}}</text> -->
			<!-- <button @click="change">登录</button> -->
		</view>
			<view class='order'>
				<view class='order-title'>
					<view>我的订单</view>
					<view>查看全部 ></view>
				</view>
				<view class='order-list'>
					<view class='order-item'>
						<image class='order-img' src="../user/待付款.png" mode=""></image>
						<view>待付款</view>
					</view>
					
					<view class='order-item'>
						<image class='order-img' src="../user/待评价.png" mode=""></image>
						<view>待评价</view>
					</view>
					
					<view class='order-item'>
						<image class='order-img' src="../user/退款.png" mode=""></image>
						<view>退款</view>
					</view>
				</view>
			</view>	
			<view class="my-content">
				
				<view class="my-content-item">
					<view>我的收藏</view>
					<view>></view>
				</view>
				
				<view class="my-content-item">
					<view>浏览历史</view>
					<view>></view>
				</view>
				
				<view class="my-content-item">
					<view>帮助中心</view>
					<view>></view>
				</view>
				
				<view class="my-content-item">
					<view>意见反馈</view>
					<view>></view>
				</view>
				
				<view class="my-content-item">
					<view>联系客服</view>
					<view>></view>
				</view>
			</view>
		<view>
			<button @click="goback()">退出登录</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:{},acc:'',islogin:'',list:''
	
			}
		},
		onLoad() {
			const value = uni.getStorageSync('account');
			this.acc = value;
			this.getdata()
			this.islogin = sessionStorage.getItem("isLogin");
		},
		methods: {
			getdata(){
				uni.request({
					url:'/api/api/login_lo',
					method:"POST",
					data:{account:this.acc},
					success: (res) => {
						if(res.data.length !== 0){
							this.list = res.data[0].name
						}else{
							this.list = '请登录'
						}
					}
				})
			},
			change(){
				
				if(this.islogin == 'null' || this.islogin == null){
					console.log("islogin",this.islogin)
					uni.showModal({
						title: '提示',
						content: '是否前往登录界面',
						success: function (res) {
							if (res.confirm) {
								uni.navigateTo({
									url:"/pages/user/login/login"
								})
							}
						}
					});
				}
			},
			goback(){
				uni.reLaunch({
					url: '/pages/user/login/login'
				});
				uni.setStorageSync('account','');
				sessionStorage.setItem("isLogin",null)
			}
		}
	}
</script>

<style>
	.box{
		display: flex;
		width: 100%;
		height: 150px;
		background-color: #ff8284;
		border-radius: 10px;
	},
	.image{
		margin:auto 0;
		width: 60px;
		height: 60px;
		border-radius: 50px;
		/* margin: 10px; */
		margin-left: 40px;
	},
	.app{
		margin:auto 0;
		margin-left: 20px;
		font-size: 20px;
	},
	.order-title{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx;
		
	},
	.order-img{
		width: 30px;
		height: 30px;
	},
	.order-list{
		padding:20rpx;
		display: flex;
	},
	.order-item{
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	},
	.my-content{
		padding:0 20rpx;
		margin: 20rpx 0;
	},
	.my-content-item{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding:20rpx 0;
		border-bottom: 2px solid #CCCCCC;
	}
	
</style>
